#define DEBUG
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;

int min(int a, int b) {
	return a<b ? a : b;
}

int max(int a, int b) {
	return a>b ? a : b;
}

class Bignum {
	public:
		static const int maxlen=150, k=10000;
		int v[maxlen+1];

		int& operator[](int x) {
			return v[x];
		}

		void zero() {
			memset(v, 0, sizeof v);
		}

		Bignum& pop() {
			for (; v[0] && !v[v[0]]; v[0]--);
			return *this;
		}

		int cmp(Bignum &a) {
			if (v[0]<a[0]) {
				return -1;
			} else if (v[0]>a[0]) {
				return 1;
			} else {
				for (int i=v[0]; i>0; i--) {
					if (v[i]>a[i]) {
						return 1;
					} else if (v[i]<a[i]) {
						return -1;
					}
				}
				return 0;
			}
		}

		Bignum& min(Bignum &a) {
			if (cmp(a)>0) {
				*this = a;
			}
			return *this;
		}

		void read() {
			zero();

			static char s[501];
			char c;
			scanf(" %c", &c);
			if (c=='-') {
				scanf("%s", s);
			} else if (c=='0') {
				return;
			} else {
				ungetc(c, stdin);
				scanf("%s", s);
			}
			int len=strlen(s);
			v[0] = 1;
			for (int i=len-1, j=1; i>=0; i--, j*=10) {
				if (j>=k) {
					j/=k, v[0]++;
					v[v[0]] = 0;
				}
				v[v[0]] += (s[i]-'0')*j;
			}
		}

		void shr(Bignum &a, int t) {
			zero();
			v[0] = a[0]+t;
			for (int i=1; i<=a[0]; i++) {
				v[i+t] = a[i];
			}
		}

		Bignum& add(Bignum &a, Bignum &b) {
			zero();
			int t=max(a[0], b[0]);
			for (int i=1; i<=t; i++) {
				v[i] += a[i]+b[i];
				v[i+1] += v[i]/k;
				v[i] %= k;
			}
			v[0] = t+1;
			return pop();
		}

		Bignum& dec(Bignum &a, Bignum &b) {
			zero();
			for (int i=1; i<=a[0]; i++) {
				v[i] += a[i]-b[i];
				if (v[i]<0) {
					v[i] += k;
					v[i+1]--;
				}
			}
			v[0] = a[0];
			return pop();
		}

		Bignum& mul(Bignum &a, Bignum &b) {
			zero();
			for (int i=1; i<=a[0]; i++) {
				for (int j=1; j<=b[0]; j++) {
					v[i+j-1] += a[i]*b[j];
					v[i+j] += v[i+j-1]/k;
					v[i+j-1] %= k;
				}
			}
			v[0] = a[0]+b[0];
			return pop();
		}

		Bignum& div(Bignum &a, int b) {
			zero();
			int rest=0;
			for (int i=a[0]; i>0; i--) {
				v[i] = (rest*k+a[i])/b;
				rest = (rest*k+a[i])%b;
			}
			v[0] = a[0];
			return pop();
		}

		Bignum& div(Bignum &a ,Bignum &b) {
			static Bignum rest, temp[2], ans;

			rest = a;
			ans.zero();
			for (int i=a[0]; i>0; i--) {
				int j;
				for (int l=0, r=k-1, mid; l<=r; ) {
					temp[0].zero();
					mid = (l+r)/2;
					temp[0][0] = 1, temp[0][1] = mid;
					temp[1].mul(b, temp[0]);
					temp[0].shr(temp[1], i-1);
					if (temp[0].cmp(rest)>0) {
						r = mid-1;
					} else {
						l = mid+1;
						j = mid;
					}
				}

				ans[i] = j;
				temp[0][0] = 1, temp[0][1]=j;
				temp[1].mul(b, temp[0]);
				temp[0].shr(temp[1], i-1);
				temp[1].dec(rest, temp[0]);
				rest = temp[1];
			}
			ans[0] = a[0];

			if (rest[0]) {
				temp[0].zero();
				temp[0][0] = 1, temp[0][1] = 1;
				add(ans, temp[0]);
			} else {
				*this = ans;
			}
			return pop();
		}

		void print() {
			printf("%d", v[v[0]]);
			for (int i=v[0]-1; i>0; i--) {
				printf("%04d", v[i]);
			}
			printf("\n");
		}
};

Bignum one, two;

int main() {
#ifdef DEBUG
	freopen("src.in", "r", stdin);
	freopen("src.out", "w", stdout);
#endif

	one[0] = 1, one[1] = 1;
	two[0] = 1, two[1] = 2;

	int t;
	scanf("%d", &t);
	for (int ti=1; ti<=t; ti++) {
		static Bignum x, y, l, ans, t, ta, tb, tc, td, te;
		x.read(), y.read(), ta.read();
		l.dec(ta, one);
		if ((x[1]+y[1])%2) {
			printf("Poor MLG!\n");
		} else {
			t=l;
			ans.add(x, y), t.min(x).min(y);
			if (x[1]%2==0) {
				ans.min(tc.add(ta.div(tb.div(x, 2), l), td.div(te.div(y, 2), l)));
			}
			if ((x[1]-t[1])%2) {
				tb.add(ta.dec(x, t), one);
				tc.add(ta.dec(y, t), one);
				ta.div(td.div(tb, 2), l);
				tb.div(td.div(tc, 2), l);
				ans.min(td.add(tc.add(ta, tb), one));

				ta.mul(l, two);
				if ((x[1]-ta[1])%2) {
					tb.dec(ta, one);
					ta = tb;
				}
				if (x.cmp(ta)>=0 && y.cmp(ta)>=0) {
					td.div(tb.dec(x, ta), 2);
					te.div(tb.dec(y, ta), 2);
					ta.add(tb.div(td, l), tc.div(te, l));
					ans.min(tb.add(ta, two));
				}
			} else {
				tb.dec(x, t);
				tc.dec(y, t);
				ta.div(td.div(tb, 2), l);
				tb.div(td.div(tc, 2), l);
				ans.min(td.add(tc.add(ta, tb), one));

				ta.mul(l, two);
				if ((x[1]-ta[1])%2) {
					tb.dec(ta, one);
					ta = tb;
				}
				if (x.cmp(ta)>=0 && y.cmp(ta)>=0) {
					td.div(tb.dec(x, ta), 2);
					te.div(tb.dec(y, ta), 2);
					ta.add(tb.div(td, l), tc.div(te, l));
					ans.min(tb.add(ta, two));
				}
			}
			ans.print();
		}
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}
